package com.dyc.controller;

import com.dyc.pojo.Emp;
import com.dyc.pojo.LoginInfo;
import com.dyc.pojo.Result;
import com.dyc.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j

@RestController
public class LoginController {

    @Autowired
    private EmpService empService;

    @PostMapping("/login")
    public Result getLoginInfo(@RequestBody Emp emp) {
        log.info("登录:{}", emp);
        LoginInfo info = empService.login(emp);
        //对info判断是否有数据
        if (info != null) {
            return Result.success(info);
        }
        return Result.error("用户名或密码错误");
    }
}
